﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Web
{
    public partial class WebCallMsg : FromentWebCommon
    {
        public int clientId = 0;
        public string uname = string.Empty;
        public List<Model.view_call_msg> list = new List<Model.view_call_msg>();
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
          
            if (string.IsNullOrEmpty(Common.UICookie.ReadCookie("ClientUId")))
            {
                Response.Write("<script>alert('请先登录！');window.location.href='default.aspx';</script>");
            }
            else
            {
                int cid = Convert.ToInt32(Common.UICookie.ReadCookie("ClientUId"));
                if (cid > 0)
                {
                    clientId = cid;
                    var umodel = Common.SqlExption.GetList<Model.tb_user>().FirstOrDefault(c => c.Id.Equals(cid));
                    if (umodel != null)
                    {
                        uname = umodel.name;

                    }
                    var ulist = Common.SqlExption.GetList<Model.tb_user>();
                    var lists = Common.SqlExption.GetList<Model.tb_call_msg>().Where(c => c.client_id.Equals(cid)&&c.order_number.Equals(string.Empty));
                    var lists1 = Common.SqlExption.GetList<Model.tb_call_msg>();
                    if (lists.Count() > 0)
                    {
                        var temp = from c in lists
                                   join d in ulist on c.client_id equals d.Id
                                   select new Model.view_call_msg()
                                   {
                                       cient = d.name,
                                       client_id = c.client_id,
                                       contents = c.contents,
                                       create_time = c.create_time,
                                       Id = c.Id,
                                       order_number = c.order_number,
                                       server_id = c.server_id,
                                       call_msg = c.call_msg
                                   };
                        list = temp.ToList();
                    }
                }
            }
           
        }
       

      
    }
}